<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div align="center">
    <p>
        电影名:<input type="text" id="uname" name="uname"  />
        主演:<input type="text" id="actstar" name="actstar" />
        <input type="button"  class="nav" value="提交" />
    </p>
    <table border="1" id="ta">
    </table>
    <div id="pager">
    </div>
</div>
</body>
</html>
<script src="statics/jquery-1.8.3.min.js"></script>
<script>
    $(function () {
        function a(page,uname,actstar) {
            $.ajax({
                url:"http://localhost:8082/showfilm",
                type:"GET",
                data:{"pageIndex":page,"uname":uname,"actstar":actstar},
                dataType:"JSON",
                success:function (re) {
                    var html="";
                    html+="<tr>";
                    html+="<td>编号</td>\n" +
                        "  <td>电影名</td>\n" +
                        "  <td>主演</td>\n" +
                        "  <td>导演</td>\n" +
                        "  <td>票价</td>\n" +
                        "  <td>上映时间</td>\n" +
                        "  <td>简介</td>\n" +
                        "  <td>点赞数</td>\n" +
                        "  <td>众评</td>\n" +
                        "  <td>操作</td>";
                    $(re.list).each(function (i,re) {
                        html+="<tr>";
                        html+="<td>"+re.id+"</td>";
                        html+="<td>"+re.uname+"</td>";
                        html+="<td>"+re.actstar+"</td>";
                        html+="<td>"+re.director+"</td>";
                        html+="<td>"+re.price+"</td>";
                        html+="<td>"+re.releaseDate+"</td>";
                        html+="<td>"+re.brief+"</td>";
                        html+="<td>"+re.fabulous+"</td>";
                        html+="<td>"+re.content+"</td>";
                        html+="<td><input type='button' class='zan' value='点赞' uid='"+(re.id)+"'>" +
                            "<a href='update.html?id="+re.id+"'>众评</a></td>";
                        html+="</tr>";
                        $("#ta").html(html);
                    });
                    p="<span>第"+re.pageIndex+"页/共"+re.totalPageCount+"页</span>";
                    p+="<a href='javascript:;' class='nav' page='1'>首页</a>";
                    if(re.hasPrevious){
                        p+="<a href='javascript:;' class='nav' page='"+(re.pageIndex-1)+"'>上一页</a>";
                    }else{
                        p+="<a href='javascript:;' class='nav' page='1'>上一页</a>";
                    }
                    if(re.hasNext){
                        p+="<a href='javascript:;' class='nav' page='"+(re.pageIndex+1)+"'>下一页</a>";
                    }else{
                        p+="<a href='javascript:;' class='nav' page='"+re.totalPageCount+"'>下一页</a>";
                    }
                    p+="<a href='javascript:;' class='nav' page='"+re.totalPageCount+"'>尾页</a>";
                    $("#pager").html(p);
                    $(".zan").click(function () {
                        var id = $(this).attr("uid");
                        $.ajax({
                            url : "checkaddes",
                            TYPE : "GET",
                            data : {
                                id : id
                            },
                            dataType : "JSON",
                            success : function(result) {
                                if (result == 1) {
                                    alert("点赞成功!");
                                } else {
                                    alert("点赞失败!");
                                }
                            }
                        })
                    })
                }
            })
        };
        a();
        $(".nav").live("click",function(){
            var page=$(this).attr("page");
            var uname=$("#uname").val();
            var actstar=$("#actstar").val();
            a(page,uname,actstar);
        })
    })
</script>